package com.aorise.exception;
import com.aorise.utils.StatusDefine;
import com.aorise.utils.StatusDefineMessage;
import com.aorise.utils.json.JsonResponseData;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

/**
 * @Auther: zhouhao
 * @Date: 2019/4/26
 * @Description: 全局异常
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(AuthorizationException.class)
    public String handleShiroException(Exception ex,HttpServletRequest request) {
        return new JsonResponseData(false, "", StatusDefine.PERMISSIONDENIED,
                    StatusDefineMessage.GetMessage(StatusDefine.PERMISSIONDENIED), "").toString();
    }

}
